<%@page contentType="text/html" pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>

	<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="Keywords" content="中软国际-微信公众号管理后台">
        <meta name="Description" content="中软国际-微信公众号管理后台">
        <link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/btn.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/register_icss.css" />
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />
		<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>
		<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
		<script type="text/javascript" src="<%=path%>/include/layer/layer.js"></script>	
		
		<style type="text/css">
		.dropdown-submenu:hover>.dropdown-menu{display:none}
		.td1{
			width:15%;
			height:35px;
			text-align:right;
			padding-right:6px;
		}
		.rightTd{
			width:80%;
			height:35px;
			text-align:left;
			padding-left:6px;
		}
		.inputr{
			min-width:16%;
		}
		</style>
		
		<title>微信公众号管理后台</title>
        
        <script type="text/javascript">
        	function _checkUserAccountExist(obj){
        		var personAccount= obj.value;
        		$.ajax({
			 		type:"GET",
					url:"<%=path%>/clerkAccount/checkUserAccountExist.do",
					data: {
						personAccount : personAccount
					},
					dataType:"json",
					async : false, //同步执行
					success:function(data){
						if(data.success){
						} else {
							parent.swal("OMG", data.msg, "error");
							obj.value = "";
						}
					}
				})
        	}
        	//保存，提交form表单
			function submitForm(){
				var flag = checkInfo();
				if(flag){
					var url = "<%=path%>/clerkAccount/saveClerk";
					fm.action=url;
					fm.submit();
				}
			}
			//验证输入是否符合规范
			function checkInfo(){
				var personAccount = $("#personAccount").val();
				personAccount = $.trim(personAccount);// 去除收尾空格
				if(personAccount == ''){
				    parent.layer.alert("店员帐号不能为空!");
					return false;
				}
				
				var personName = $("#personName").val();
				personName = $.trim(personName);// 去除收尾空格
				if(personName == ''){
					parent.layer.alert("店员姓名不能为空!");
					return false;
				}
				
				var loginPwd = $("#loginPwd").val();
				loginPwd = $.trim(loginPwd);// 去除收尾空格
				if(loginPwd == ''){
					parent.layer.alert("登录密码不能为空!");
					return false;
				}
				
				var mobile = $("#mobile").val();
				mobile = $.trim(mobile);// 去除收尾空格
				var reg = /^0?1[3-8][0-9]\d{8}$/;
				if(mobile == ''){
					parent.layer.alert("手机号码不能为空!");
					return false;
				}else if(!reg.test(mobile)){
					parent.layer.alert("手机号码输入不符合规范");
					$("#mobile").val("");
					return false;
				}
				
				var email = $("#email").val();
				email = $.trim(email);// 去除收尾空格
				var re = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
				if(email == ''){
					parent.layer.alert("邮箱帐号不能为空!");
					return false;
				}else if (!re.test(email)){
					parent.layer.alert("邮箱帐号输入不符合规范!");
					$("#email").val("");
					return false;
				}
				var checkFlag = false;
				var checkBox = document.getElementsByName("isKf");
				for(var j=0;j<checkBox.length; j++){
					checkFlag = checkBox[j].checked;
					if(checkFlag){
						j = 2;
					}
				}
				if(!checkFlag){
					parent.layer.alert("请选择是否客服！");
					return false;
				}
				return true;
			}
			
		</script>
	</head>
	<body class="theme-blue" data-theme="theme-blue">
    	<div id="contentDiv" style="padding: 4px;width:99%;" >
			<div style="width:100%;height:30px;border-bottom:1px solid #ADADAD;">
				<div class="toptil"><c:if test="${operat == 'add'}">添加</c:if><c:if test="${operat == 'edit'}">编辑</c:if>店员</div>
			</div>
			<form id="fm" name="fm" class="form-horizontal" method="post"  novalidate="novalidate">
				<input type='hidden' id='operat' name='operat' value="${operat}" />
				<input type='hidden' id='personUuid' name='personUuid' value="${clerkMap.PERSON_UUID }" />
				<div style="width:100%;margin-top:20px;margin-left:10px;">
					<table style="width:100%;"  >
						<tr>
							<td class="td1" nowrap>店员帐号：</td>
							<td class="rightTd" nowrap>
								<c:if test="${operat eq 'add'}">
								<input id="personAccount" class="inputr" name="personAccount" value="${clerkMap.PERSON_ACCOUNT }" onchange="_checkUserAccountExist(this)" type="text" data-rule-required="true">
								</c:if>
								<c:if test="${operat eq 'edit'}">
								${clerkMap.PERSON_ACCOUNT }
								<input id="personAccount" class="inputr" name="personAccount" value="${clerkMap.PERSON_ACCOUNT }" type="hidden" />
								</c:if>
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap>店员姓名：</td>
							<td class="rightTd" nowrap>
							<input id="personName" class="inputr" name="personName"  value="${clerkMap.PERSON_NAME }" type="text" data-rule-required="true"data-rule-number="true">	
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap>登录密码：</td>
							<td class="rightTd" nowrap>
							<input id="loginPwd" class="inputr" name="loginPwd" value="123456" type="password" data-rule-required="true" data-rule-number="true">	
							<span style="padding-left:4px;">默认密码:123456</span>
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap>手机号码：</td>
							<td class="rightTd" nowrap>
							<input id="mobile" class="inputr" name="mobile" value="${clerkMap.MOBILE }" type="text" data-rule-required="true"data-rule-number="true">	
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap>邮箱帐号：</td>
							<td class="rightTd" nowrap>
							<input id="email" class="inputr" name="email" value="${clerkMap.EMAIL}" type="text" data-rule-required="true"data-rule-number="true">	
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap>是否客服：</td>
							<td class="rightTd" nowrap>
								<label class="radio inline">
									<input id="isKf" name="isKf" value="1" <c:if test="${clerkMap.IS_KF eq 1}">CHECKED="checked"</c:if> type="radio">
									是
								</label>
								<c:if test="${operat == 'edit'}">
								<label class="radio inline">
									<input id="isKf" name="isKf" value="0" <c:if test="${clerkMap.IS_KF eq 0}">CHECKED="checked"</c:if>  type="radio">
									否
								</label>
								</c:if>
								<c:if test="${operat == 'add'}">
								<label class="radio inline">
									<input id="isKf" name="isKf" value="0" CHECKED="checked"  type="radio">
									否
								</label>
								</c:if>
							</td>
						</tr>
						<tr>
							<td class="td1" nowrap></td>
							<td class="rightTd" nowrap>
								<div class="form-actions">
									<a onclick="submitForm();" class="btn btn-primary">保存</a>
									<a onclick="window.history.go(-1);" class="btn">取消</a>
								</div>
							</td>
						</tr>
					</table>
				</div>
			</form>
		</div>
	</body>
	<script type="text/javascript">
  	$(document).ready(function(){
		_reHeight();
	});
	function _reHeight(){
		var main = $(window.parent.document).find("#rightFrame");
		var mainheight = $("#contentDiv").height();
		main.height(mainheight);
	}
	</script>
</html>